package shuishijie.suishijie.model;



import java.util.Calendar;
import java.util.List;

import shuishijie.suishijie.util.AppUtil;

/**
 * Created by mindx on 2017/8/29.
 */

public class HotTimeGoods {


    /**
     * beginTime : 2017-08-25 13:35:13
     * data : []
     * endTime : 2017-08-26 13:35:23
     * status : -2
     */

    public String beginTime;
    public String endTime;
    public int status;
    public List<GoodsInfo> data;

    public String getDiscription() {
        String ret = null;
        String time = null;
        Calendar begin = Calendar.getInstance();
        begin.setTime(AppUtil.parserDate(beginTime));

        int date = begin.get(Calendar.DATE);

        Calendar tmpDate = Calendar.getInstance();
        int today = tmpDate.get(Calendar.DATE);
        tmpDate.add(Calendar.DATE, -1);
        int yesterday = tmpDate.get(Calendar.DATE);
        tmpDate.add(Calendar.DATE, 2);
        int tomorrow = tmpDate.get(Calendar.DATE);

        // (-1:关闭，-2：结束，1：未开始 0：已开抢 2：抢购中)
        if (status < 0) {
          //  ret = GloblaData.getHotTimeStatus(beginTime, endTime, status);
        } else if (begin.getTimeInMillis() < System.currentTimeMillis()) {
            long countDown = AppUtil.parserDate(endTime).getTime() - System.currentTimeMillis();
            if (countDown > 0) {
                ret = "距结束还剩  ";
                long dd = countDown / 24 / 3600 / 1000;
                long hh = (countDown / 3600 / 1000) % 24;
                long mm = (countDown / 60 / 1000) % 60;
                long ss = (countDown / 1000) % 60;

                if (dd > 0) {
                    ret += dd + "天";
                }
                ret += String.format("%02d:", hh);
                ret += String.format("%02d:", mm);
                ret += String.format("%02d", ss);
            } else {
                ret = "已结束";
            }
        } else {
            if (date == today) {
                ret = "今天";
            } else if (date == yesterday) {
                ret = "昨天";
            } else if (date == tomorrow) {
                ret = "明天";
            } else {
                ret = String.format("%02d月%02d日", begin.get(Calendar.MONTH) + 1, begin.get(Calendar.DATE));
            }
            ret += String.format("%02d:%02d", begin.get(Calendar.HOUR_OF_DAY), begin.get(Calendar.MINUTE));
            ret += "开抢";
        }
        return ret;
    }

}
